package com.personal.test.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloWorld {

    @Autowired
    private JavaMailSender mailSender;

    @GetMapping("/hello")
    public String helloWorld(){
        return "世界，你好，2021年对我温柔点。";
    }

    @PostMapping("/send")
    public void sendSimpleMail(){
        SimpleMailMessage message = new SimpleMailMessage();
        message.setTo("1503386669@qq.com");
        message.setSubject("用户新增");
        message.setText("哈哈哈");
        message.setFrom("1503386669@qq.com");
        mailSender.send(message);
    }
}
